﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransCend.Util.Page;

namespace TransCend.Result
{
    [Serializable]
    public class DataTablesResult<T>: Result where T : IDictionary
    {

        public DataTablesResult()
        {

        }

        public DataTablesResult(PageListResult<T> lr)
        {
            recordsTotal = lr.total;
            data = lr.rows;
            errorCode = lr.errorCode;
            message = lr.message;
            success = lr.success;
        }

        public DataTablesResult(PageListResult<T> lr, int draw)
            : this(lr)
        {
            this.draw = draw;
        }

        public DataTablesResult(PageTools<T> pagetools, int draw)
        {
            this.draw = draw;

            recordsTotal = pagetools.GetTotalCount();
            data = pagetools.List;
            success = true;
        }

        public int recordsTotal
        {
            get;
            set;
        }

        public int recordsFiltered
        {
            get { return recordsTotal; }
        }

        public IList<T> data
        {
            get;
            set;
        }

        public int draw
        {
            get;
            set;
        }
    }
}
